-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update action filter execution process to run using the continuation style #44
Conversation
…uation flow The action filter wrapper has been replaced, and a new autofac filter interface defined with a registered adapter around the old style.
…, and cleaned up registrations.
…dual interface exception.
Merging now autofac#43 in autofac has been done.
It looks like the ASP.NET web stack is licensed under Apache 2.0. Reading through that license, I gather this is the relevant bit:
I read that as:
I mean, ideally we wouldn't have copy/paste code because of the licensing issues there, but it happens. So... in files affected, something like: // This software is part of the Autofac IoC container
// Copyright (c) 2013 Autofac Contributors
// https://autofac.org
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//
// Portions of this file come from the Microsoft ASP.NET web stack, licensed
// under the Apache 2.0 license. You may obtain a copy of the license at
// http://www.apache.org/licenses/LICENSE-2.0 In the main LICENSE we'd add something like:
Does that sound about right, @alexmg / @nblumhardt ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really, really awesome. I think if you can add the licensing bit, we can go for it. Thank you for all the hard work here, and I'm sorry for being a bit out-of-pocket lately.
Thanks @tillig, I've updated the AutofacActionFilterAdapter with the file comment and updated the LICENSE file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
Also, now you're ok with the approach, I'll put documentation updates together on the docs repo for these changes. |
I gather this is a 4.3.0 kind of release since it's backwards compatible but a new feature. Does that sound right to you (current release is 4.2.1)? If so, let me know when you're ready to release and I can help with that. |
Yeah, it's a 4.3.0; I already updated the appveyor file in a previous PR (for making the registration support more powerful). I'm happy to release, unless you want to wait for the documentation changes? |
Nope, I'm livin' on the edge today. Let's release this bad boy! :) |
Sweet; is it mostly just a push from myget to nuget? Then create the release entry in the repo? |
|
Ok, let me know if there's any of that I can help with. In case you need it for the release note: Resolved issues in this release are:
|
Perfect, thanks! I'm drafting up the release now. |
Released! |
Awesome, thanks Travis. I'll put the documentation updates together soonish. |
Fixes #34
This change removes the
ActionFilterWrapper
and replaces it with theContinuationActionFilterWrapper
, which implementsIActionFilter
rather than deriving fromActionFilterAttribute
.The logic in this new wrapper uses the continuation style to call each nested filter.
There is a new
IAutofacContinuationActionFilter
that allows users to directly implement a filter that uses continuations. The oldIAutofacActionFilter
is still supported, through the registration of an adapter that wraps the old-style filter in aAutofacActionFilterAdapter
that replicates the behaviour ofActionFilterAttribute
.Regardless of the type of filter used, the async context is correctly maintained, so you can set the TransactionScope, for example, in the OnActionExecutingAsync of a normal filter and it will be maintained in the WebAPI action.
In the new continuation-style filter you can wrap the 'next' filter in a using block with a transaction scope and everything works as you would hope.
New tests have been added that explicitly validate that TransactionScope is maintained in all the right places for both filter types.
Note: I have directly copied the code from the ASP.NET source that invokes the OnActionExecutedAsync method, because I consider it to be the reference source of how to do it (and I've noted as such in the comments). Is this ok from a license/re-use perspective?
As far as I can tell this is not a breaking change of API or behaviour (thanks almost entirely to Autofac adapters).